package com.slkj.shilixiaoyuanapp.ui.teacher.tool.homework;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.slkj.shilixiaoyuanapp.R;
import com.slkj.shilixiaoyuanapp.base.BaseLazyFragment;
import com.slkj.shilixiaoyuanapp.entity.HomeWorkDetailEntity;
import com.slkj.shilixiaoyuanapp.entity.ToolWorkListEntity;
import com.slkj.shilixiaoyuanapp.view.DividerItemDecoration;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created  on 2018-07-20
 *
 * @author 唐开阔
 * @describe 已交
 */
public class WorkDetailUpLoadFragment extends BaseLazyFragment {
    @BindView(R.id.recycer)
    RecyclerView recycerType;
    BaseQuickAdapter adapter;
    List<HomeWorkDetailEntity.DeliveredEntity> toolWorkListEntityList = new ArrayList<>();

    @Override
    protected int getResId() {
        return R.layout.fragment_tool_work_detail_upload;
    }

    @Override
    protected void onRealLoaded() {

        recycerType.addItemDecoration(new DividerItemDecoration(getContext(), LinearLayoutManager.VERTICAL));
        recycerType.setLayoutManager(new LinearLayoutManager(getContext()));
        adapter = new BaseQuickAdapter<HomeWorkDetailEntity.DeliveredEntity, BaseViewHolder>(R.layout.item_tool_work_upload, toolWorkListEntityList) {
            @Override
            protected void convert(BaseViewHolder helper, final HomeWorkDetailEntity.DeliveredEntity item) {
                helper.setText(R.id.tv_name, item.getName());
                helper.setText(R.id.tv_level, item.getLevel());
                helper.setText(R.id.tv_info, item.getComment());
                switch (item.getLevel()) {
                    case "A":
                        helper.setImageResource(R.id.tv_level,R.drawable.ic_homework_a);
                        break;
                    case "B":
                        helper.setImageResource(R.id.tv_level,R.drawable.ic_homework_b);
                        break;
                    case "C":
                        helper.setImageResource(R.id.tv_level,R.drawable.ic_homework_c);
                        break;
                    case "D":
                        helper.setImageResource(R.id.tv_level,R.drawable.ic_homework_d);
                        break;
                }
            }
        };
        recycerType.setAdapter(adapter);

//        if (toolWorkListEntityList.size() == 0) {
//            adapter.setEmptyView(R.layout.statelayout_empty);
//        }
    }

    public void onDataBack(List<HomeWorkDetailEntity.DeliveredEntity> data) {
        toolWorkListEntityList = data;
    }
}
